<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript">
        var num = parseFloat(prompt("请您输入一个数字(大于2)"))
        var sum = 0;
        if (num >= 2) {
            for (var i = 2; i <= num; i++) {
                sum += parseFloat((i + 1) / i)
            }
        } else {
            alert("请输入满足要求的数字")
        }
        console.log(sum);
        alert("和为" + sum) 
    </script>
</head>

<body>
</body>

</html>